<?php
require_once ('../lib/config.php');
require_once ('../lib/facebook.php');
require_once ('../lib/friends.php');
require_once ('../lib/friend.php');
require_once ('../lib/test.php');

require_once ('../lib/init.php');

$isValid = checkSessionValidity();

if(!$isValid){
    print $login_button;
    exit();
}else{
    print $logout_button;
}


    print("<br/>============================================");
    print("<br/>WALL POST TEST");    
    $friends = processFriends();
    
    //Verify function
    //count all friends' posts then it must appear on either of both communication
    $me = getOneself();
    $count = 0;
    if(!empty($me)){
        $posts = processWallPosts($me['id']);
print_r($posts);        
        if(!empty($posts)){
            foreach($posts as $post){
                //if it's friends' posts, just count
                if($me['id'] != $post['from']['id']){
                    $count++;
                } else {
                //if it's my posts then only if there is a comment, count unique commentors
                    $comments = processComments($post['id']);
//print_r($comments);                    
                    $commentors = array();
                    if(!empty($comments) && is_array($comments)){
                        foreach($comments as $comment){
                            if(!empty($comment['from']['id']) && $comment['from']['id'] != $me['id']){
                                array_push($commentors, $comment['from']['id']);
                            }
                        }
                    }
                    $commentors = array_unique($commentors);
                    $count += count($commentors);
                }
            }
        }        
    }
    print("<br/>Total Number of Communication : ".$count);
    processingWallPostsOnMyWall($friends);
    countTotalNumberOfCommunication($friends);


    